package org.wuyichun.gift.service.impl;

import org.springframework.beans.BeanUtils;
import org.wuyichun.gift.domain.Tenant;
import org.wuyichun.gift.dto.TenantRegisterDto;
import org.wuyichun.gift.mapper.TenantMapper;
import org.wuyichun.gift.service.ITenantService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.wuyichun.gift.util.AjaxResult;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wuyichun
 * @since 2024-10-07
 */
@Service
public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> implements ITenantService {
    @Override
    public AjaxResult insert1(TenantRegisterDto tenantRegisterDto) {
        Tenant tenant = TenantRegisterDtoToTenant(tenantRegisterDto);
        super.insert(tenant);
        return AjaxResult.me().setSuccess(true).setResultObj(tenant);
    }

    private Tenant TenantRegisterDtoToTenant(TenantRegisterDto tenantRegisterDto) {
        Tenant tenant = new Tenant();
        BeanUtils.copyProperties(tenantRegisterDto,tenant);
        tenant.setRegisterTime(new Date());
        return tenant;
    }
}
